/*
 * Platillo.java
 *
 * Created on 12 de octubre de 2007, 03:08 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package data;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Entity class Platillo
 * 
 * @author Fanny Paola Vadillo Herrera
 * @author Luis Manuel Pineda Llano
 */
@Entity
@Table(name = "platillo")
@NamedQueries( {
        @NamedQuery(name = "Platillo.findById", query = "SELECT p FROM Platillo p WHERE p.id = :id"),
        @NamedQuery(name = "Platillo.findByNombre", query = "SELECT p FROM Platillo p WHERE p.nombre = :nombre"),
        @NamedQuery(name = "Platillo.findByPrecio", query = "SELECT p FROM Platillo p WHERE p.precio = :precio"),
        @NamedQuery(name = "Platillo.findByClasificacion", query = "SELECT p FROM Platillo p WHERE p.clasificacion = :clasificacion"),
        @NamedQuery(name = "Platillo.findClasificacion", query = "SELECT DISTINCT p.clasificacion FROM Platillo p"),
        @NamedQuery(name = "Platillo.findAll", query = "SELECT p FROM Platillo p")
    })
public class Platillo implements Serializable {

    @Id
    @Column(name = "id", nullable = false)
    private Integer id;

    @Column(name = "nombre", nullable = false)
    private String nombre;

    @Column(name = "precio", nullable = false)
    private double precio;

    @Column(name = "clasificacion", nullable = false)
    private String clasificacion;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "platillo")
    private Collection<OrdenPlatillo> ordenPlatilloCollection;
    
    /** Creates a new instance of Platillo */
    public Platillo() {
    }

    /**
     * Creates a new instance of Platillo with the specified values.
     * @param id the id of the Platillo
     */
    public Platillo(Integer id) {
        this.id = id;
    }

    /**
     * Creates a new instance of Platillo with the specified values.
     * @param id the id of the Platillo
     * @param nombre the nombre of the Platillo
     * @param precio the precio of the Platillo
     * @param clasificacion the clasificacion of the Platillo
     */
    public Platillo(Integer id, String nombre, double precio, String clasificacion) {
        this.id = id;
        this.nombre = nombre;
        this.precio = precio;
        this.clasificacion = clasificacion;
    }

    /**
     * Gets the id of this Platillo.
     * @return the id
     */
    public Integer getId() {
        return this.id;
    }

    /**
     * Sets the id of this Platillo to the specified value.
     * @param id the new id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * Gets the nombre of this Platillo.
     * @return the nombre
     */
    public String getNombre() {
        return this.nombre;
    }

    /**
     * Sets the nombre of this Platillo to the specified value.
     * @param nombre the new nombre
     */
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    /**
     * Gets the precio of this Platillo.
     * @return the precio
     */
    public double getPrecio() {
        return this.precio;
    }

    /**
     * Sets the precio of this Platillo to the specified value.
     * @param precio the new precio
     */
    public void setPrecio(double precio) {
        this.precio = precio;
    }

    /**
     * Gets the clasificacion of this Platillo.
     * @return the clasificacion
     */
    public String getClasificacion() {
        return this.clasificacion;
    }

    /**
     * Sets the clasificacion of this Platillo to the specified value.
     * @param clasificacion the new clasificacion
     */
    public void setClasificacion(String clasificacion) {
        this.clasificacion = clasificacion;
    }

    /**
     * Gets the ordenPlatilloCollection of this Platillo.
     * @return the ordenPlatilloCollection
     */
    public Collection<OrdenPlatillo> getOrdenPlatilloCollection() {
        return this.ordenPlatilloCollection;
    }

    /**
     * Sets the ordenPlatilloCollection of this Platillo to the specified value.
     * @param ordenPlatilloCollection the new ordenPlatilloCollection
     */
    public void setOrdenPlatilloCollection(Collection<OrdenPlatillo> ordenPlatilloCollection) {
        this.ordenPlatilloCollection = ordenPlatilloCollection;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Platillo.  The result is 
     * <code>true</code> if and only if the argument is not null and is a Platillo object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Platillo)) {
            return false;
        }
        Platillo other = (Platillo)object;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return nombre;
    }
    
}
